package com.hctforgreen.greenservice.model;

import org.json.JSONException;
import org.json.JSONObject;
/**
 * 16、检查App版本
 * @author Tallen Zhai
 *
 */
public class CheckVersionEntity extends BaseEntity {

	private static final long serialVersionUID = -9130516995986776298L;
	public String isNew = "";
	public String theNewVersionCode = "";
	public String updateFlag = "";
	public String statusCode = "";
	public String msg = "";
	
	public enum UpdateFlag{
		Enforce,//强制更新
		Recommend,//推荐更新
		Ignore//忽略更新
	}
	public final static String STATE_CODE = "statusCode";
	public final static String MSG = "msg";
	
	private final static String IS_NEW = "isNew";
	private final static String IS_NEW_VERSION_CODE = "theNewVersionCode";
	private final static String UPDATE_FLAG = "updateFlag";
	public static CheckVersionEntity parse(JSONObject jsonObject)throws JSONException{
		CheckVersionEntity bean = new CheckVersionEntity();
		if(jsonObject.has(STATE_CODE)){
			bean.statusCode = jsonObject.getString(STATE_CODE);
		}
		if(jsonObject.has(MSG)){
			bean.msg = jsonObject.getString(MSG);
		}
		
		if(jsonObject.has(IS_NEW)){
			bean.isNew = jsonObject.getString(IS_NEW);
		}
		if(jsonObject.has(IS_NEW_VERSION_CODE)){
			bean.theNewVersionCode = jsonObject.getString(IS_NEW_VERSION_CODE);
		}
		if(jsonObject.has(UPDATE_FLAG)){
			bean.updateFlag = jsonObject.getString(UPDATE_FLAG);
		}
		return bean;
	}
	
}
